import mockjs from 'mockjs';

const genRsp = (respData: object) =>
    mockjs.mock({
        success: true,
        code: 200,
        ...respData
    });

export default [
    // 获取部门列表
    {
        url: '/api/department/list',
        method: 'get',
        response: genRsp({
            data: [
                {
                    id: '1',
                    name: '研发部',
                    children: [
                        {
                            id: '2',
                            name: '前端组'
                        },
                        {
                            id: '3',
                            name: '后端组'
                        }
                    ]
                },
                {
                    id: '4',
                    name: '产品部',
                    children: [
                        {
                            id: '5',
                            name: '产品组'
                        }
                    ]
                },
                {
                    id: '6',
                    name: '设计部',
                    children: [
                        {
                            id: '7',
                            name: '设计1组'
                        },
                        {
                            id: '8',
                            name: '设计2组'
                        }
                    ]
                }
            ]
        })
    },
    // 获取部门和用户列表
    {
        url: '/api/deptAndUser/list',
        method: 'get',
        response: genRsp({
            data: [
                {
                    id: '1',
                    name: '研发部',
                    personals: [
                        {
                            name: '李四',
                            uid: '1',
                            roles: [
                                {
                                    roleId: '1',
                                    roleName: '研发经理'
                                },
                                {
                                    roleId: '2',
                                    roleName: '产品经理'
                                }
                            ]
                        },
                        {
                            name: '张三',
                            uid: '2',
                            roles: [
                                {
                                    roleId: '1',
                                    roleName: '研发经理'
                                }
                            ]
                        }
                    ],
                    children: [
                        {
                            id: '2',
                            name: '前端组',
                            personals: [
                                {
                                    name: '王五',
                                    uid: '3',
                                    roles: [
                                        {
                                            roleId: '3',
                                            roleName: '员工'
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            id: '3',
                            name: '后端组'
                        }
                    ]
                },
                {
                    id: '4',
                    name: '产品部',
                    children: [
                        {
                            id: '5',
                            name: '产品组',
                            personals: [
                                {
                                    name: '李四',
                                    uid: '1',
                                    roles: [
                                        {
                                            roleId: '1',
                                            roleName: '研发经理'
                                        },
                                        {
                                            roleId: '2',
                                            roleName: '产品经理'
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                },
                {
                    id: '6',
                    name: '设计部',
                    children: [
                        {
                            id: '7',
                            name: '设计1组',
                            personals: [
                                {
                                    name: '张前进',
                                    uid: '8',
                                    roles: [
                                        {
                                            roleId: '2',
                                            roleName: '产品经理'
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            id: '8',
                            name: '设计2组'
                        }
                    ]
                }
            ]
        })
    },
    // 获取用户列表
    {
        url: '/api/user/list',
        method: 'get',
        response: genRsp({
            data: [
                {
                    name: '李四',
                    uid: '1',
                    roles: [
                        {
                            roleId: '1',
                            roleName: '研发经理'
                        },
                        {
                            roleId: '2',
                            roleName: '产品经理'
                        }
                    ],
                    departments: [
                        {
                            id: '1',
                            name: '研发部'
                        },
                        {
                            id: '4',
                            name: '产品部'
                        }
                    ]
                },
                {
                    name: '张三',
                    uid: '2',
                    roles: [
                        {
                            roleId: '1',
                            roleName: '研发经理'
                        }
                    ],
                    departments: [
                        {
                            id: '1',
                            name: '研发部'
                        }
                    ]
                },
                {
                    name: '王五',
                    uid: '3',
                    roles: [
                        {
                            roleId: '3',
                            roleName: '员工'
                        }
                    ],
                    departments: [
                        {
                            id: '2',
                            name: '前端组'
                        }
                    ]
                },
                {
                    name: '张前进',
                    uid: '8',
                    roles: [
                        {
                            roleId: '2',
                            roleName: '产品经理'
                        }
                    ],
                    departments: [
                        {
                            id: '7',
                            name: '设计1组'
                        }
                    ]
                }
            ]
        })
    },
    {
        url: '/api/long/list',
        method: 'get',
        response: genRsp({
            'data|10-20': [
                {
                    id: '@guid()',
                    name: '@cname()',
                    phone: '@phone()',
                    'roles|1-3': [
                        {
                            id: '@guid()',
                            name: '@cname()'
                        }
                    ]
                }
            ]
        })
    }
];
